/**
 * 
 * for SHOW loading PROGRESS...
 * 
 * view for PROGRESS BAR...
 * 
 * 2009-11-9
 * 
 * 
 * */
package com.components.progressbar
{
	import core.section.Controller;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	import gs.TweenLite;
	import gs.easing.Expo;

	public class ProgressBarView extends Controller
	{
		//START...
		
		
		//PROPERTY...
		private var slider:Sprite;
		
		private var bar:DisplayObject;
		
		private var txtProgress:TextField;
		
		private var _progress:Number;
		
		private const EASE_DELAY:Number = .5;
				
				
		//CONSTRUCTOR...
		public function ProgressBarView(target:DisplayObject)
		{
			
			super(target);
			
			init();
						
		}
		
		//METHODS...
		
		//initializing...
		private function init():void
		{
			
			var target:Sprite = this.target as Sprite;
			
			target.visible = false;
			
			slider = target.getChildByName("slider") as Sprite;
			
			bar = target.getChildByName("bar");
			
			slider.mask = bar;
			
			txtProgress = target.getChildByName("txtProgress") as TextField;
			
			txtProgress.autoSize = TextFieldAutoSize.LEFT;
						
		}
		
		
		// set progress...
		internal function set progress(val:Number):void
		{
			
			_progress = val;
			
			bar.width = slider.width * val;
			
			txtProgress.text = String(Math.floor(val * 100)) + "%";			
			
		}
		
		// get progress...
		internal function get progress():Number
		{
			return _progress;
		}
		
		//show...
		internal function show():void
		{
			
			target.visible = true;
			target.alpha = 1;
		}
			
		//hide...
		internal function hide():void
		{
			target.visible = false;		
			progress = 0;
		}
		
		//END..
	}
}